<%@ Page Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeFile="AdminNews.aspx.cs"
    Inherits="admin_AdminNews" Title="The Forecast Exchange - News management" ValidateRequest="false" %>

<%@ Register TagPrefix="tfe" TagName="NewsForm" Src="~/controls/forms/NewsForm.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <h1>
        Manage news</h1>
    <tfe:NewsForm runat="server" ID="_newsForm" />
    <h2>
        All news</h2>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
        DataKeyNames="ID" DataSourceID="AccessDataSource1" 
        Width="100%" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
        CellPadding="2" ForeColor="#333333" GridLines="Vertical">
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
        <Columns>
            <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                SortExpression="ID" />
            <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" ItemStyle-HorizontalAlign="Center" />
            <asp:BoundField DataField="News_date" HeaderText="News date" SortExpression="News_date" ItemStyle-HorizontalAlign="Center" />
            <asp:BoundField DataField="Prediction_id" HeaderText="Prediction ID" SortExpression="Prediction_id" ItemStyle-HorizontalAlign="Center"/>
            <asp:BoundField DataField="Player_id" HeaderText="Player ID" SortExpression="Player_id" ItemStyle-HorizontalAlign="Center"/>
            <asp:CommandField ShowSelectButton="True" ButtonType="Button" SelectText="Edit" />
        </Columns>
        <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
        <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
        <AlternatingRowStyle BackColor="#F7F7F7" />
    </asp:GridView>
    <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/ForecastExchange.mdb"
        DeleteCommand="DELETE FROM [NewsItem] WHERE [ID] = ?" InsertCommand="INSERT INTO [NewsItem] ([ID], [Title], [News_message], [News_date], [Prediction_id], [Player_id]) VALUES (?, ?, ?, ?, ?, ?)"
        SelectCommand="SELECT * FROM [NewsItem] ORDER BY [News_date] DESC" UpdateCommand="UPDATE [NewsItem] SET [Title] = ?, [News_message] = ?, [News_date] = ?, [Prediction_id] = ?, [Player_id] = ? WHERE [ID] = ?">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="News_message" Type="String" />
            <asp:Parameter Name="News_date" Type="DateTime" />
            <asp:Parameter Name="Prediction_id" Type="Int32" />
            <asp:Parameter Name="Player_id" Type="Int32" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="ID" Type="Int32" />
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="News_message" Type="String" />
            <asp:Parameter Name="News_date" Type="DateTime" />
            <asp:Parameter Name="Prediction_id" Type="Int32" />
            <asp:Parameter Name="Player_id" Type="Int32" />
        </InsertParameters>
    </asp:AccessDataSource>
</asp:Content>
